package com.zhiche.lisa.integration.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.zhiche.lisa.core.utils.HttpClientUtil;
import com.zhiche.lisa.integration.dao.model.PushSubSystem;
import com.zhiche.lisa.integration.service.IPushSubSystemService;
import com.zhiche.lisa.integration.service.PodService;
import com.zhiche.lisa.integration.surpports.enums.TableStatusEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PodServiceImpl implements PodService {

    @Autowired
    private IPushSubSystemService systemService;

    @Override
    public void synPodStatus(String param) {
        if (StringUtils.isNotBlank(param)){
            Wrapper<PushSubSystem> ew = new EntityWrapper<>();
            ew.eq("type", TableStatusEnum.STATUS_15.getCode());
            List<PushSubSystem> subSystems = systemService.selectList(ew);
            for (PushSubSystem subSystem : subSystems) {
                HttpClientUtil.postJson(subSystem.getUrl(),null,param,subSystem.getSocketTimeOut());
            }
        }
    }
}
